package simtester.server

class Team {

	String name
	
    static hasMany = [users: User, testcases: TestCase, testsuites: TestSuite]
    
	static constraints = {
		users nullable: true
		testcases nullable: true
        testsuites nullable: true
	}

    static mapping = {
        testcases lazy: false
        testsuites lazy: false
    }
    
    def findTestRuns() {
        //TODO: Need to return testruns from Test Suites too
        def testruns = []
        this.testcases.each {
            testruns += TestRun.findAllByTestcase(it)
        }
        
        this.testsuites.each {
            testruns += TestRun.findAllByTestsuite(it)
        }
        
        testruns = testruns.sort { it.dateCreated }.reverse()
        return testruns
    }
}
